package com.example.javabasic.thread.classtwo.singleton.demo1;
//懒汉
public class SingleTwo {
    private static volatile SingleTwo instance;
    private SingleTwo(){

    }

    //可以加类锁或者 双重检查锁  两种方式
    //类锁性能不行
    public static SingleTwo getInstance(){
        if(instance == null){
            synchronized (SingleTwo.class){
                if(instance == null){
                    instance = new SingleTwo();
                }
            } 
        }
        return SingleTwo.instance;
    }

}
